home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-02 / nrpas13.zip / LINMIN.PAS < prev    next >
Pascal/Delphi Source File  |  1991-04-29  |  773b  |  32 lines

  1. PROCEDURE linmin(VAR p,xi: glnarray; n: integer; VAR fret: real);
  2. (* Programs using routine LINMIN must define the type
  3. TYPE
  4.    glnarray = ARRAY [1..n] OF real;
  5. They must also declare the variables
  6. VAR
  7.    ncom: integer;
  8.    pcom,xicom: glnarray;
  9. in the main routine. Also the function FUNC referenced by BRENT
  10. and MNBRAK must be set to return the function F1DIM. *)
  11. CONST
  12.    tol=1.0e-4;
  13. VAR
  14.    j: integer;
  15.    xx,xmin,fx,fb,fa,bx,ax: real;
  16. BEGIN
  17.    ncom := n;
  18.    FOR j := 1 TO n DO BEGIN
  19.       pcom[j] := p[j];
  20.       xicom[j] := xi[j]
  21.    END;
  22.    ax := 0.0;
  23.    xx := 1.0;
  24.    bx := 2.0;
  25.    mnbrak(ax,xx,bx,fa,fx,fb);
  26.    fret := brent(ax,xx,bx,tol,xmin);
  27.    FOR j := 1 TO n DO BEGIN
  28.       xi[j] := xmin*xi[j];
  29.       p[j] := p[j]+xi[j]
  30.    END
  31. END;
  32.